package top.ucat.x.file.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import top.ucat.box.cloud.common.result.Result;
import top.ucat.box.cloud.common.result.SystemResult;
import top.ucat.box.starter.oauth.common.pojo.User;
import top.ucat.box.starter.oauth.common.util.UserUtil;
import top.ucat.x.file.beans.AliMobileDetailVo;
import top.ucat.x.file.beans.AliMobileStsVo;
import top.ucat.x.file.service.FileService;

/**
 * @Auther: Jun
 * @Date: 2019/9/16 17:16
 * @Description:
 */

@RestController
@RequestMapping("mobile/file")
@Api(tags = {"移动端上传接口"})
public class FileMobileController {

    @Autowired
    private FileService fileService;

    @ApiOperation(value = "阿里上传信息", notes = "")
    @PostMapping("ali/detail")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "module", value = "模块路径", required = true, paramType = "query", dataType = "String"),
    })
    public Result<AliMobileDetailVo> getMobileDetail(@RequestParam String module) {
        User user= UserUtil.getUser();
        AliMobileDetailVo mobileDetail = fileService.getMobileDetail(module, user.getId());
        return SystemResult.OK.getResult(mobileDetail);
    }

    @ApiIgnore
    @RequestMapping("ali/sts")
    public ResponseEntity getMobileSts() {
        AliMobileStsVo aliMobileSts = fileService.getAliMobileSts("","");
        return ResponseEntity.ok(aliMobileSts);
    }

}
